﻿using System;
using codeGen.Model;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using RazorEngine;
using RazorEngine.Templating;
namespace codeGen
{
    class Program
    {
        static void Main(string[] args)
        {
            Host.CreateDefaultBuilder()
                .ConfigureAppConfiguration((hostContext, config) =>
                {
                    config.AddJsonFile("config.json", true, reloadOnChange: true);
                    if (args != null)
                    {
                        config.AddCommandLine(args);
                    }
                })
                .ConfigureServices((context, services) =>
                {
                    services.AddHostedService<GenrateService>();
                    services.Configure<List<TaskConfig>>(context.Configuration.GetSection("TaskConfigs"));
                })
                .UseConsoleLifetime().RunConsoleAsync();

        }
    }
}